import menuConfig from '@/config/menu'
import {fromJS} from 'immutable'
import {actionTypes} from './index'

const defaultState = fromJS({
    menu: menuConfig,
    menuTreeNode: [],
    selectedMenu: ['home']
})

export default (state = defaultState, action)=>{
    switch (action.type) {
        case actionTypes.UPDATE_MENU_TREE:
            return state.set('menuTreeNode',action.value)
        case actionTypes.UPDATE_ACTIVE_MENU_NAME:
            return state.set('selectedMenu',action.value)
        default:
            return state
    }
}
